<%--
  Created by IntelliJ IDEA.
  User: 小新
  Date: 2021/12/26
  Time: 1:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        boolean flag = false;
        String value = null;
        Cookie[] cookies = request.getCookies();
        if (cookies != null && cookies.length > 0) {
            for (Cookie cookie : cookies) {
                if (cookie.getName().equals("username")) {
                    value = cookie.getValue();
                    if (value != null) {
                        flag = true;
                        break;
                    }
                }
            }
        }
        System.out.println(flag);
        if (flag) {
            session.setAttribute("username", value);
            response.sendRedirect("/index1");
        } else {
            response.sendRedirect("/admin/login.jsp");
        }
    %>
</body>
</html>
